﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Space.QueryEngine
{
    /// <summary>
    /// Defines the status of a space item.
    /// </summary>
    public enum SpaceObjectStatus
    {
        /// <summary>
        /// Defines a locked space item.
        /// </summary>
        Locked = 0,

        /// <summary>
        /// Defines an unlocked space item.
        /// </summary>
        Unlocked = 1,

        /// <summary>
        /// Defines a locked and an unlocked space item.
        /// </summary>
        Both = 2
    }

    /// <summary>
    /// This class provides the execution of a query over a space container.
    /// </summary>
    [Serializable]
    public class SpaceQueryEngine
    {
        /// <summary>
        /// The list of space items.
        /// </summary>
        private List<SpaceItem> items;

        /// <summary>
        /// Initializes a new instance of the <see cref="SpaceQueryEngine"/> class.
        /// </summary>
        /// <param name="items">The list of space items.</param>
        public SpaceQueryEngine(ref List<SpaceItem> items)
        {
            this.items = items;
        }

        /// <summary>
        /// Gets or sets the list of space items.
        /// </summary>
        /// <value>The list of space items.</value>
        public List<SpaceItem> Items
        {
            get { return this.items; }
            set { this.items = value; }
        }

        /// <summary>
        /// Executes a specified query.
        /// </summary>
        /// <param name="query">The query to execute.</param>
        /// <returns>The result of the specified query.</returns>
        public uint[] ExecuteQuery(AbstractSpaceQuery query)
        {
            return query.ExecuteQuery(ref this.items);
        }
    }
}